﻿
/*
 * Twipler - Twitter Web Client with features.
 *  
 *  Copyright (C) 2009, 2010. Ian Quigley
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details. 
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */

using System;
using Twipler.Data.Access;

namespace Twipler.Data.Entity.Theme
{
    public class Block : BaseChild
    {
        [EditIgnore]
        public virtual Design ParentDesign { get; set; }

        [EditOrder(30)]
        public virtual string Code { get; set; }

        [EditOrder(35)]
        public virtual string Description { get; set; }

        [EditOrder(40)]
        [EditStringType(EditStringType.Types.LargeText)]
        public virtual string Content { get; set; }

        [EditIgnore]
        public override Base  Parent
        {
	        get { return ParentDesign;	}
        }

        public override string ToString()
        {
            return Code;
        }

        public virtual Block Clone(Design parent)
        {
            Block newBlock = new Block()
            {
                Id = 0,
                Code = this.Code,
                Content = this.Content,
                Description = this.Description,
                ParentDesign = parent
            };

            Factory.Block.Save(newBlock);

            return newBlock;
        }
    }
}
